package cn.itcast.javabase;

/**
 * @title: A01
 * @Author Zhou
 * @Date: 2022/1/18 13:49
 * @Version 1.0
 */
public class A01 {
    public static void main(String[] args) {
        HomeWork01 homeWork01 = new HomeWork01();
//        double[] arr = {12.3, 43.4, 66.66, 89.9};
//        double[] arr = {1};
        double[] arr = null;
        Double max = homeWork01.max(arr);
        if (max != null) {
            System.out.println("max = " + max);
        } else {
            System.out.println(" 传入的集合有误 ");
        }
    }
}

class HomeWork01 {
    //自动装箱和自动拆箱
    public Double max(double[] arr) {
        double tem = 0;
        if (arr != null && arr.length > 0) {
            for (int i = 0; i < arr.length; i++) {
                if (arr[i] > tem) {
                    tem = arr[i];
                }
            }
            return tem;
        } else {
            return null;
        }
    }
}
